package com.jocata;

import java.util.List;

/*import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import com.jcms.db.entity.CustomerPrincipal;*/

public class RemoveNoiseAndAlias {

	/**
	 * @param args
	 */
	public String removeNoiseWords(String str,List list){
		String str1[]=str.toLowerCase().split("\\s+");
		String str2="";
		for(int i=0; i< str1.length;i++){
			if(list.contains(str1[i])){
				str1[i]=null;
			}else{
			str2=str2+" "+str1[i];
			}
		}
		if(str2.trim().startsWith("mr.")){
			return str2.substring(str2.indexOf("mr.")+3, str2.length()).trim();
		}else if(str2.trim().startsWith("mrs.")){
			return str2.substring(str2.indexOf("mrs.")+4, str2.length()).trim();
		}
		return str2.trim();
	}
	
	public static String removeAliasWords(String str,List list){
		String str1[]=str.split("\\s+");
		String str2="";
		for(int i=0; i< str1.length;i++){
			if(list.contains(str1[i])){
				str1[i]=null;
			}else{
			str2=str2+" "+str1[i];
			}
		}
		return str2;
	}
	
/*	public static void main(String[] args){
		EntityManagerFactory emf =
	            Persistence.createEntityManagerFactory("");
	        EntityManager em = emf.createEntityManager();
	        Query q = em.createQuery("SELECT cp FROM CustomerPrincipal cp");
	          List<CustomerPrincipal> list = q.getResultList();
	          for (CustomerPrincipal customerPrincipal : list) {
	               //System.out.println(customerPrincipal.get);
	          }
	}*/

}
